package ch7.ex;

public class Cunqianren extends Thread {
	private Accout ac;

	public Cunqianren(String n, Accout ac) {
		super(n);
		this.ac = ac;
	}

	@Override
	public void run() {
		while (true) {
			synchronized (ac) {
				ac.deposit(3000);
				System.out.println(super.getName() + "存钱3000元，现在余额是：" + ac.getMoney() + "元");
				ac.notifyAll();
			}

			try {
				sleep(1500);
			} catch (InterruptedException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}

		}
	}
}
